const fs = require('fs');
const wget = require('node-wget');
baseUrl = 'https://storage.googleapis.com/learnjs-data/checkpoint_zoo/squeezenet1_1/'

function download(url) {
  return new Promise(function(resolve, reject) {
    wget(url, (err,header,body)=>{
      if(err) {
        reject(err);
      }else {
        resolve(body)
      }
    })
  })
}


(async function (){
  try {
    let body = await download(baseUrl+'manifest.json')
    let manifest = JSON.parse(body)
    for( let k in manifest){
      let ret = await download(baseUrl+manifest[k].filename)
      console.log('download OK:', k)
    }
  }
  catch (err) {
    console.log('出错啦:'+err.message);
  }
} ())

